package ro.gateway.aida.charts;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

import org.jfree.data.XYSeries;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Jun 20, 2004
 * Time: 12:18:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class TimeChartDataMan {
	public static void populate_xy_dataset(
		  XYSeries xy_dataset, 
		  String language,
		  ChartWizzard$ActionForm form) {
		if (form.search_results == null) return;
		ArrayList distinct_rows = ChartUtils.getDistinctValues(form.search_results,
			  1, language,
			  form.x_axe_criteria.startsWith("year#"),
			  form); // serii
		ArrayList distinct_columns = null;
		if (form.x_axe_group_criteria != null) {
			distinct_columns = ChartUtils.getDistinctValues(form.search_results,
				  2, language,
				  form.x_axe_group_criteria.startsWith("year#"),
				  form); // grupuri
		}

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		for (int i = 0; i < distinct_rows.size(); i++) {
			String row = (String) distinct_rows.get(i);
			Number value = null;
			value = ChartUtils.compute_chart_value(row, null, form);
			try {
				long time = sdf.parse(row).getTime();
				xy_dataset.add(time, value);
			} catch (Throwable th) {
			}
		}
	}

}
